package com.neuedu.hisadmin.controller;

import com.neuedu.hisadmin.dto.RegisterDTO;

import com.neuedu.hisadmin.entity.Register;
import com.neuedu.hisadmin.service.IRegisterService;
import com.neuedu.hisadmin.dto.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;

@RestController
@RequestMapping("/register")
public class RegisterController {

    @Autowired
    private IRegisterService registerService;

    // 查询可退号记录接口
    @PostMapping("/refund/query")
    public Result<List<Register>> queryRefundableRegisters(@RequestBody RegisterDTO dto) {
        List<Register> registers = registerService.queryRefundableRegisters(dto);
        return Result.success(registers);
    }

    // 执行退号接口
    @PostMapping("/refund/do")
    public Result<Boolean> processRefund(@RequestParam Integer registerId) {
        boolean success = registerService.doRefund(registerId);
        return success ? Result.success(true) : Result.error(500,"退号失败，请稍后重试");
    }
}